<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 <title>1L_a Programming Language Standard</title>
 <meta name="author" content="">
 <meta name="generator" content="stx2any">
 <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>1L_a Programming Language Standard</h1>

<h2>The 1L_a Programming Language Standard, 2005 (<q>1L_a105</q>)</h2>

<p>Published by the 1L_a Standardization Committee

<h2>Overview</h2>

<p>1L_a is a powerful and expressive programming language in which program
code is two-dimensional. Data are stored within a simulated virtual
machine consisting of an array of bits.

<p>The goal of this standards document is to provide a clear guideline for
would-be implementors of the 1L_a programming language, so that, going
forward, implementors and programmers alike can coagulate in an infernal,
synergistic quagmire.

<h2>Section 1: Source Code Representation</h2>

<h3>Section 1.1: Instructions</h3>

<p>Source code in 1L_a consists of a rectangular, two-dimensional array of
symbols representing instructions. This array's width and height must
each be finite and no less than 1.

<p>The symbols are in a finite alphabet containing at least two distinct
members. Of these, the symbol equal to that found in the upper left
corner of the code array represents the GO instruction, while all other
symbols in the alphabet represent the STOP instruction.

<h3>Section 1.2: Internal Representation of Code</h3>

<p>It is implementation-defined how an array of source code is represented
on disk.

<h2>Section 2: Data Access</h2>

<h3>Section 2.1: The Data Array</h3>

<p>1L_a programs have access to an array of data bits, capable of storing
the values 0 and 1. This array is bounded on the left.

<p>From a theoretical perspective, the array is unbounded on the right, so
that no limit is placed on the number of bits available in the array.
However, implementations on physical machines may provide a limited
number of bits to the right, due to the machines' finite memory. Such
implementations should terminate with an error if a 1L_a program
attempts to access memory past the rightmost available bit.

<p>For the purposes of this Standard, the leftmost three bits shall be
referred to as TL0, TL1, and TL2 (in order).

<p>Before a 1L_a program starts, all bits in the data array shall be set
to 0.

<h3>Section 2.2: The Data Pointer</h3>

<p>Besides the data array, 1L_a programs maintain the additional state of
a <em>data pointer</em>. The data pointer refers to a particular bit in the
data array. All operations directly available to a 1L_a program for
manipulating the data array use the bit underneath the data pointer.

<p>Initially, the data pointer refers to TL2.

<p>Moving the data pointer to the left when it is already at TL0 results
in undefined behavior.

<h2>Section 3: Execution</h2>

<h3>Section 3.1: The Instruction Pointer</h3>

<p>Further state is maintained in a 1L_a program in an <em>instruction pointer</em>.
The instruction pointer consists of a location within the source code
array, as well as a direction of travel: up, left, right, or down.

<p>Initially, the instruction pointer refers to the instruction in the
upper left corner of the source code array, and its direction is down.

<h3>Section 3.2: Movement</h3>

<p>Execution proceeds as follows: first the instruction under the
instruction pointer is executed, then the instruction pointer moves
forward one cell in the code array.

<h3>Section 3.3: Instructions</h3>

<h4>Section 3.3.1: GO</h4>

<p>The GO instruction performs a different action depending on the
instruction pointer's direction:

<ul><li><strong>Up</strong>: The data pointer is moved one bit to the right.
<li><strong>Down</strong>: No action is taken.
<li><strong>Left</strong>: The data pointer is moved one bit to the left, and then the
bit at the data pointer is flipped.
<li><strong>Right</strong>: No action is taken.

</ul><h4>Section 3.3.2: STOP</h4>

<p>The STOP instruction causes the instruction pointer to move backwards
one cell in the code array. Then the bit under the data pointer is
examined. If it is 0, the instruction pointer turns 90 degrees to the
left. Otherwise, the instruction pointer turns 90 degrees to the right.

<h3>Section 3.4: Termination</h3>

<p>If at any time the instruction pointer attempts to move up beyond the
topmost row of the code array or left beyond its leftmost column, the
program terminates.

<p>Attempting to move the instruction pointer outside the bounds of the
code array on the right or bottom does not necessarily terminate the
program, but rather results in undefined behavior.

<h2>Section 4: Input and Output</h2>

<h3>Section 4.1: Memory-Mapped I/O</h3>

<p>Input and output are memory-mapped. Flipping the bit at TL0 thus has
the side effect of an input or output operation, as follows: If TL1 is
1, then a bit corresponding to the value of TL2 is output. Otherwise, a
bit is input and its value saved in TL2.

<h3>Section 4.2: Buffering</h3>

<p>1L_a is often implemented for machines on which input and output are in
terms of bytes, not bits. On such machines, bytes shall be converted to
series of 8 bits and vice versa using the convention that the most
significant bit appears first.

<p>Additionally, on such machines, input and output shall be buffered with
a buffer size of at least one byte. The output buffer is not flushed at
program termination, so any bits waiting to be output at that point,
but which have not been output because they do not comprise a full
byte, shall be lost.
</body>
</html>
